package com.example.tool;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;

@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
public class ToolApplication {
    //
    @Autowired
    private Environment environment;

    public static void main(String[] args) {
        ConfigurableApplicationContext context = SpringApplication.run(ToolApplication.class, args);
        Object o = System.getProperties().get("server.port");
        Integer port = null;
        if (o != null) {
            port = Integer.parseInt(o.toString());
        }
        if (port == null || port <= 0) {
            port = Integer.parseInt(context.getEnvironment().getProperty("server.port"));
        }
        System.out.println("用浏览器打开 http://127.0.0.1:" + port + "/index.html 即可使用该排版数据读取工具");
    }

}
